package cn.tuling.v1;

import java.util.ArrayList;
import java.util.List;

/**
 * 需求： 把公司中的所有人员信息都打印汇报上去
 */
public class VisitorTest {
    public static void main(String[] args) {
        for (Employee employee : mockEmployee()) {
            employee.report();
        }
    }

    public static List<Employee> mockEmployee() {
        List<Employee> list = new ArrayList<>();
        CommonEmployee employee = new CommonEmployee();
        CommonEmployee employee2 = new CommonEmployee();
        Manager manager = new Manager();
        list.add(employee);
        list.add(employee2);
        list.add(manager);

        employee.setName("张三");
        employee.setSex(Employee.MALE);
        employee.setSalary(10000);
        employee.setJob("编写Java程序，绝对的蓝领、苦工加搬运工。");

        employee2.setName("李四");
        employee2.setSex(Employee.FEMALE);
        employee2.setSalary(18000);
        employee2.setJob("页面美工，审美素质太不流行了！");


        manager.setName("王五");
        manager.setSex(Employee.MALE);
        manager.setSalary(50000);
        manager.setPerformance("基本是负值，但是我会拍马屁啊。");

        return list;
    }
}

abstract class Employee {
    public final static int MALE = 1;
    public final static int FEMALE = 0;

    private int salary;
    private String name;
    private int sex;

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public final void report() {
        String info = "姓名：" + this.name + "\t";
        info = info + "性别：" + (this.sex == FEMALE ? "女" : "男") + "\t";
        info = info + "薪水：" + this.salary + "\t";
        //获得员工的其他信息
        info = info + this.getOtherInfo();
        System.out.println(info);
    }

    public abstract String getOtherInfo();
}

class CommonEmployee extends Employee {
    private String job;

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    @Override
    public String getOtherInfo() {
        return "工作：" + this.job + "\t";
    }
}


class Manager extends Employee {
    private String performance;

    public String getPerformance() {
        return performance;
    }

    public void setPerformance(String performance) {
        this.performance = performance;
    }

    @Override
    public String getOtherInfo() {
        return "业绩：" + this.performance + "\t";
    }
}

